package org.seefly.iprint.converter;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.springframework.core.convert.converter.Converter;


public class String2DatesConverter implements Converter<String, List<Date>> {
    //static Logger logger = Logger.getLogger(String2DateConverter.class);
    private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");

    @Override
    public List<Date> convert(String source) {
        List<Date> dateList = new ArrayList<>();
        try {
            String[] list = source.split(" - ");
            if(list != null) {
                for(String d : list) {
                    dateList.add(sdf.parse(d));
                }
            }
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return dateList;
    }

}
